﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace RoketSolutions.SP2010.Infrostructure.Common.Extensions
{
    public static class Enumerable
    {
        public static bool IsNullOrEmpty<T>(this T[] array)
        {
            return array == null || array.Length == 0;
        }

        public static bool IsNullOrEmpty(this ICollection collection)
        {
            return collection == null || collection.Count == 0;
        }

        public static bool IsNullOrEmpty<T>(this IList<T> collection)
        {
            return collection == null || collection.Count == 0;
        }

        public static bool Contains(this IList<string> collection, string value, bool ignoreCase)
        {
            return collection.Any(valueToCompare => value.Equals(valueToCompare, StringComparison.InvariantCultureIgnoreCase));
        }
    }
}